package objid

import (
	"fmt"
	"go.mongodb.org/mongo-driver/bson/primitive"
	"serve/shared/id"
)

func FormID(id fmt.Stringer) (primitive.ObjectID, error) {
	return primitive.ObjectIDFromHex(id.String())
}

func MustFormId(id fmt.Stringer) primitive.ObjectID {
	formID, err := FormID(id)
	if err != nil {
		panic(err)
	}

	return formID
}

func ToAccountId(oid primitive.ObjectID) id.AccountID {
	return id.AccountID(oid.Hex())
}

func ToTripID(oid primitive.ObjectID) id.TripID {
	return id.TripID(oid.Hex())
}
